#ifndef SESSIONMANAGER_H
#define SESSIONMANAGER_H

#include <map>

#include "ISerializable.h"
#include "Session.h"

class SessionManager : public ISerializable
{
public:
  typedef std::map<std::string, Session> SessionMap;
  typedef std::pair<std::string, Session> SessionPair;

  SessionManager()
  {    
  }

  virtual ~SessionManager()
  {
  }

  const SessionMap& sessions() const { return m_sessions; }
  const Session *sessionById(const std::string &id) const;
  virtual bool serialize(const std::string& fileName) const;
  virtual bool deserialize(const std::string& fileName);
  std::string newSessionId() const;
  void clear() { m_sessions.clear(); }
  void insert(const Session& history)
  {
    m_sessions[history.id()] = history;
  }

  int size() const { return static_cast<int>(m_sessions.size()); }

private:
  SessionMap m_sessions;
};

#endif //SESSIONMANAGER_H